package com.mall.goods.controller;

import com.mall.commons.utils.CommonResult;
import com.mall.goods.service.CmsSubjectService;
import com.mall.model.vo.CommonPage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/subject")
public class CmsSubjectController {

    @Autowired
    private CmsSubjectService cmsSubjectService;

    /**
     * 根据专题名称分页获取商品专题
     *
     * @param keyword
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GetMapping("/list")
    public CommonResult list(String keyword, Integer pageNum, Integer pageSize) {
        CommonPage commonPage = cmsSubjectService.list(keyword, pageNum, pageSize);
        return CommonResult.success(commonPage);
    }

    /**
     * 获取全部商品专题
     *
     * @return
     */
    @GetMapping("listAll")
    public CommonResult listAll() {
        List resultList = cmsSubjectService.listAll();
        return CommonResult.success(resultList);
    }

}
